﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using lgweb.common;
using LGCourt.Logic.BLL;
using LGCourt.Logic.NBL.DBEntities;
using System.Text;

namespace lgweb.inside.office
{
    public partial class report : NeedValidatePage
    {
        private int _pageIndex = 1;
        protected new void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!this.IsPostBack)
            {
                GetParam();
                GetList();
                this.hdOADomain.Value = System.Configuration.ConfigurationManager.AppSettings["OADomain"];
            }
        }

        private void GetParam()
        {

            this._pageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);
        }

        private void GetList()
        {
            OA bll = new OA();
            OACondition param = new OACondition();
            param.UserID = this.SessionInfo.UserID;

            List<vOATongjiBaobiao> list = (List<vOATongjiBaobiao>)bll.GetTongjiBaobiaoList(param);

            if (list != null)
            {
                int iCount = 0;
                string sClassName = "";
                StringBuilder sbHtml = new StringBuilder();

                foreach (vOATongjiBaobiao info in list)
                {
                    info.uclass=string.IsNullOrEmpty(info.uclass)?"其它":info.uclass;
                    if (sClassName != info.uclass)
                    {
                        if (iCount > 0)
                        {
                            sbHtml.Append("</ul></div>");
                            if (iCount % 2 == 0)
                            {
                                this.liSingle.InnerHtml = this.liSingle.InnerText + sbHtml.ToString();
                            }
                            else
                            {
                                this.liDedoule.InnerHtml = this.liDedoule.InnerText + sbHtml.ToString();
                            }
                            sbHtml.Clear();                           
                        }
                        iCount++;
                        sbHtml.Append(string.Format("<div class=\"g-tree w457\"><h2>{0}</h2><ul>", info.uclass));
                        sClassName = info.uclass;
                    }
                    sbHtml.Append("<li><a href=\"#\" onclick=\"this_openrpt('" + info.id + "');\">" + info.name  + "</a></li>");

                }
            }
        }
    }
}